<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>


    <script>
        /* 
                function add(x,y,f){
                    return f(x)+f(y);
                }
         
                console.log(add(-6,6,Math.abs)); */

        /*    function pf(x){
               return x*x;
           }
   
           var arr =[1,2,3,4,5,6];
           var result=arr.map(pf);
           console.log(result); */


        /* 要把[1, 3, 5, 7, 9]变换成整数13579，reduce()也能派上用场： */

        /* var arr =[1, 3, 5, 7, 9];
        console.log( arr.reduce(myFun));

        function myFun(x,y){
         return x*10+y;
        } */

        var arr = [1, 2, 3, 4, 5, 6, 7, 8];
        console.log(arr.filter(function myFunOuShu(x) {
            return x % 2 !== 0;
        })
        );




    </script>




















</body>

</html>